# Maintainer: Sarah Ottinger <schalaalexiazeal@gmail.com>

_realname=typing_extensions
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=3.7.4.3
pkgrel=1
pkgdesc='Backported and Experimental Type Hints for Python 3.5+ (mingw-w64)'
arch=('any')
url="https://github.com/python/typing/tree/master/typing_extensions"
license=('custom')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools" "git")
_tag=ffebbecbf4ad162572050ecfaac4335cc5431c24
source=("git+https://github.com/python/typing.git#tag=${_tag}")
sha256sums=(SKIP)

pkgver() {
  cd "$srcdir/typing"
  git describe --tags
}

prepare() {  
  cd "$srcdir"
  rm -rf python-build-${CARCH} | true
  cp -r "typing" "python-build-${CARCH}"
}

build() {
  msg "Python build for ${CARCH}"  
  cd "${srcdir}/python-build-${CARCH}/typing_extensions"
  sed 's/3.7.4.2/3.7.4.3/g' -i setup.py
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${CARCH}/typing_extensions"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build
  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
